const http = require('http')
const server = http.createServer()

server.on('request',(req,res)=>{
    const url = req.url
    let content = '<h1>404 not found</h1>'
    if(url==='/'||url==='/index.html'){
        content = '首页'
    }else if(url==='/about.html'){
        content = '其他页面'
    }
    res.setHeader('Content-Type','text/html; charset=utf8')  //设置响应头
    res.end(content)
})
server.listen(8080,(req)=>{
    console.log("server running at 127.0.0.1:8080")
})

